package com.zrt.pad.util;

import java.text.SimpleDateFormat;
import java.util.Locale;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;

import com.zrt.pad.commonui.SharedApplication;

public class U {
	/**
	 * Date format yyyy-MM-dd
	 */
	public static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINESE);
	
	public static final SimpleDateFormat sdft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINESE);
	
	public static final SimpleDateFormat sellsdf = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINESE);
	/**
	 * Number format
	 */
	public static final NumberUtil num = new NumberUtil();
	/**
	 * Telephone 3G
	 */
	public static final TelUtil tel = new TelUtil();
	/**
	 * DB backup & restore
	 */
	public static final DBUtil db = new DBUtil();
	/**
	 * Printer
	 */
	//public static final PrinterUtil p = new PrinterUtil();
	/**
	 * Pos
	 */
	public static final PosUtil pos = new PosUtil();
	
	/**
	 * ŇřÁŞ
	 */
//	public static final UMS ums = new UMS();
	
	public static final String GUID ="1A2B3C4D5E6F";
	public static String BlueToothAddress= "";
	
//	static {
//		String id = null;
//		try {
//			id = BluetoothAdapter.getDefaultAdapter().getAddress().replace(":", "");
//		} catch (Exception e) {
//			id = "1A2B3C4D5E6F";
//		}
//		GUID = id;
//	}
	
	public static String getVersion(){
		PackageManager pm = SharedApplication.context.getPackageManager();
		try {
			PackageInfo info = pm.getPackageInfo(SharedApplication.context.getPackageName(), 0);
			return info.versionName;
		} catch (NameNotFoundException e) {
			e.printStackTrace();
			return "异常";
		}
	}
	
	public static String getBlueToothAddress(Context ctx) {
		SharedPreferences cfg = ctx.getSharedPreferences("", 0);
		String url = cfg.getString("BlueToothAddress", BlueToothAddress);
		return url;
	}
	
	public static void setBlueToothAddress(Context context, String bluetoothaddress) {
		SharedPreferences cfg = context.getSharedPreferences(
				"", 0);
		SharedPreferences.Editor edt = cfg.edit();
		edt.putString("BlueToothAddress", bluetoothaddress);
		edt.commit();
	}

}
